package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CustomerGrade;
import com.pgybook.db.entity.domain.CustomerGradeEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CustomerGradeMapper {
    int countByExample(CustomerGradeEx example);

    int deleteByExample(CustomerGradeEx example);

    @Delete({
            "delete from customergrade",
            "where CUSTGRADEID = #{custgradeid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer custgradeid);

    @Insert({
            "insert into customergrade (NAME, DEPOSIT, ",
            "BORROWDAYS)",
            "values (#{name,jdbcType=VARCHAR}, #{deposit,jdbcType=DECIMAL}, ",
            "#{borrowdays,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "custgradeid", before = false, resultType = Integer.class)
    int insert(CustomerGrade record);

    int insertSelective(CustomerGrade record);

    List<CustomerGrade> selectByExample(CustomerGradeEx example);

    @Select({
            "select",
            "CUSTGRADEID, NAME, DEPOSIT, BORROWDAYS",
            "from customergrade",
            "where CUSTGRADEID = #{custgradeid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CustomerGrade selectByPrimaryKey(Integer custgradeid);

    int updateByExampleSelective(@Param("record") CustomerGrade record, @Param("example") CustomerGradeEx example);

    int updateByExample(@Param("record") CustomerGrade record, @Param("example") CustomerGradeEx example);

    int updateByPrimaryKeySelective(CustomerGrade record);

    @Update({
            "update customergrade",
            "set NAME = #{name,jdbcType=VARCHAR},",
            "DEPOSIT = #{deposit,jdbcType=DECIMAL},",
            "BORROWDAYS = #{borrowdays,jdbcType=INTEGER}",
            "where CUSTGRADEID = #{custgradeid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CustomerGrade record);
}
